<!DOCTYPE html>
<html lang="en">
<head>
    <title>分类管理</title>
</head>
<body class="fixed-left">
<div id="wrapper">
    <#include "../header.html">
        <link href="//cdn.bootcss.com/jquery-treetable/3.2.0/css/jquery.treetable.min.css" rel="stylesheet">
        <link href="/admin/css/jquery.treetable.theme.default.css" rel="stylesheet">

        <div class="content-page">
            <div class="content">
                <div class="container">
                    <div class="row">
                        <form class="narbar-form navbar-left" role="search" method="get" style="width: 500px;">
                            <div class="form-group col-xs-6" style="margin-top: 10px;">
                                <input type="text" value="<#if queryParam.name??>${queryParam.name}</#if>"
                                       name="name" placeholder="分类名称" class="form-control"/>

                            </div>
                            <button type="submit" class="btn btn-default col-xs-3" style="margin-top: 10px">搜索</button>
                            <a href="/admin/category/add" class="btn btn-default col-xs-2" style="margin-top: 10px;margin-left: 10px">添加分类</a>
                        </form>

                        <div class="col-md-12">
                            <table id="tabletree" class="table table-striped table-bordered">
                                <thead>
                                <tr>
                                    <th width="15%">分类名称</th>
                                    <th width="15%">文章数量</th>
                                    <th width="15%">父级编号</th>
                                    <th width="15%">排序</th>
                                    <th width="15%">状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <#list pageInfo as post>
                                    <tr data-tt-id="${post.id}" data-tt-parent-id="${post.parentid}">
                                        <td style="cursor: pointer;">${post.name}</td>
                                        <td>${post.count}</td>
                                        <td>${post.parentid}</td>
                                        <td>${post.listorder}</td>
                                        <td>
                                            <#if post.status == 1>正常
                                                <#else>禁用
                                            </#if>
                                        </td>
                                        <td>
                                            <a href="/admin/category/edit/${post.id}"
                                               class=" btn btn-primary btn-sm waves-effect waves-light m-b-5"><i
                                                    class="fa fa-edit"></i> <span>编辑</span></a>
                                            <a href="javascript:void(0)" onclick="delPost(${post.id});"
                                               class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
                                                    class="fa fa-trash-o"></i> <span>删除</span></a>
                                        </td>
                                    </tr>
                                </#list>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
<#include "../footer.html">
<script src="//cdn.bootcss.com/jquery-treetable/3.2.0/jquery.treetable.min.js"></script>

    <script type="text/javascript">
        /*<![CDATA[*/
        var tale = new $.tale();

        function delPost(cid) {
            tale.alertConfirm({
                title: '确定删除该分类吗?',
                then: function () {
                    tale.post({
                        url: '/admin/category/delete',
                        data: {id: cid},
                        success: function (result) {
                            if (result) {
                                tale.alertOkAndReload('分类删除成功');
                            } else {
                                tale.alertError('分类删除失败');
                            }
                        }
                    });
                }
            });
        }

        $("#tabletree").treetable({ expandable: true, clickableNodeNames:true });

        /*]]>*/
    </script>
</body>
</html>